<?php include_once './application/views/sys_admin/common/header.php';  ?>
<!-- admin_main -->
<div class=" definewidth m20">
	<form id="borrowForm" name="borrowForm">
	<input type="hidden" id="id" name="id" value="<?php echo $borrow['id'];?>"/>
	<table class="table table-bordered table-hover m10">
		 <tr>
	        <td class="tableleft"><span style="color:#f00;">*</span>标产品 </td>
	        <td>
	        <select id="ftype" name="ftype" class="pubput">
				<option value="0" >--请选择标产品--</option>
				<?php foreach($borrow_type as $key=>$value){?>
				<option   <?php if($borrow['ftype']==$key){?> selected="selected"<?php }?>  value="<?php echo $key;?>" ><?php echo $value;?></option><?php }?>
			</select> 
	        </td>
	        <td class="tableleft"><span style="color:#f00;">*</span>标的名称</td>
	        <td><input class="input" type="text" name="title" id="title" value="<?php echo $borrow['title'];?>" size="30" /> </td>
	        <td class="tableleft"><span style="color:#f00;">*</span>融资金额 </td>
	        <td><input type="text" class="pubinput" name="account" id="account" value="<?php echo $borrow['account'];?>" />元 </td>
	    </tr>
	    <tr>
	        <td class="tableleft"><span style="color:#f00;">*</span>收益利率 </td>
	        <td><input type="text" class="pubinput" name="apr" id="apr" value="<?php echo round($borrow['apr'],1);?>" />% </td>
	        <td class="tableleft">预约发标时间 </td>
	        <td><input type="text" id="auto_verify_time" name="auto_verify_time"  class="Wdate" style="width: 150px;" value="<?php if($borrow['auto_verify_time'] > 0){ echo date('Y-m-d H:i',$borrow['auto_verify_time']);?> <?php }?>"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})" readonly="readonly" /> </td>
	        <td class="tableleft">标的起始时间 </td>
	        <td><input type="text" id="bill_starttime" name="bill_starttime"  class="Wdate" style="width: 150px;" value="<?php if($borrow['bill_starttime'] > 0){ echo date('Y-m-d H:i',$borrow['bill_starttime']);?> <?php }?>"   onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})" readonly="readonly" /> </td>
	    </tr>
	    <tr>
	        <td class="tableleft">标的期限 </td>
	        <td>
	        <select id="time_limit" name="time_limit" onchange="billLimitTimes();" <?php if($borrow['is_day']==1){?>disabled<?php }?>>
				<?php foreach($borrow_time_limit as $key=>$value){?>
					<option value="<?php echo $key;?>" <?php if($borrow['time_limit']==$key){?> selected="selected"<?php }?> ><?php echo $value;?></option><?php }?>
			</select>按天<input type="checkbox" name="is_day" id="is_day" value="1" <?php if($borrow['is_day']==1){?>checked="checked"<?php }?> />
	        <select id="time_limit_day" name="time_limit_day" <?php if($borrow['is_day']==1){?>style="display:block;"<?php }else{?>style="display:none;"<?php }?>  onchange="billTimes();">
				<?php foreach($borrow_day_time_limit as $key=>$value){?>
				<option value="<?php echo $key;?>" <?php if($borrow['time_limit_day']==$key){?> selected="selected"<?php }?>><?php echo $value;?></option>
				<?php }?>
			</select>
	        </td>
	        <td class="tableleft">投资周期 </td>
	        <td><input type="text" readonly="readonly"   name="bill_times" id="bill_times" value="<?php echo $borrow['bill_times'];?>"  class="pubput"/>天 </td>
	        <td class="tableleft">起息时间 </td>
	        <td> 
	        	<?php foreach ($borrow_work_time as $wk=>$wt){?>
					<input type="radio"  value="<?php echo $wk;?>" <?php if($wk == $borrow['work_time']){?> checked<?php }?> id="work_time" name="work_time"><?php echo $wt;?>
				<?php }?>
	        </td>
	    </tr>
	    <tr>
	        <td class="tableleft">还款日</td>
	        <td><input type="text" id="each_time" name="each_time" class="pubinput" style="width: 150px;" value="<?php if($borrow['each_time'] > 0){ echo date('Y-m-d H:i',$borrow['each_time']);?> <?php }?>"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})" readonly="readonly" /> </td>
	        <td class="tableleft">还款方式 </td>
	        <td>
	        	<select id="style" name="style" class="pubput">
				<option value="0" >--请选择还款方式--</option>
				<?php foreach($borrow_style as $key=>$value){?><option <?php if($borrow['style']==$key){?> selected="selected"<?php }?>  value="<?php echo $key;?>"><?php echo $value;?></option><?php }?>
				</select> 
	        </td>
	        <td class="tableleft">T+N还款天数</td>
	        <td><input type="text" name="delay_repay" id="delay_repay" value="0"  class="pubinput"/></td>
	    </tr>
	    <tr>
	        <td class="tableleft">最大投资金额 </td>
	        <td><input type="text" name="most_account" id="most_account" value="<?php echo $borrow['most_account'];?>"  class="pubinput"/> </td>
	        <td class="tableleft">最小投资金额 </td>
	        <td><input type="text" name="lowest_account" id="lowest_account" value="<?php echo $borrow['lowest_account'];?>"  class="pubinput"/> </td>
	  	        <td class="tableleft"><span style="color:#f00;">*</span>资金用途 </td>
	        <td>
	        <select id="hong_fuse" name="fuse" class="pubput">
				<?php foreach($borrow_fuse as $fk=>$fuse){?>
				<option <?php if($borrow['fuse']==$fk){?> selected="selected"<?php }?> value="<?php echo $fk;?>" ><?php echo $fuse;?></option>
				<?php }?>
			</select>
			</td>
	    </tr>
	   
	     <tr>

	        <td class="tableleft"><span style="color:#f00;">*</span>借款用户编号 </td>
	        <td><input type="text" name="brw_userid" id="brw_userid" class="pubinput" value = "<?php echo $borrow['user_id'];?>"/> </td>
	        <td class="tableleft">担保用户编号 </td>
	        <td><input type="text" name="brw_userid_loan" id="brw_userid_loan"  class="pubinput" value = "<?php echo $borrow['loan_userid'];?>"/> </td>
	         <td class="tableleft"><span style="color:#f00;">*</span>逾期日利率 </td>
	        <td><input type="text" name="late_apr" id="late_apr" value = "0.0001"  class="pubinput" value = "<?php echo $borrow['late_apr'];?>"/> </td>
	    </tr>
	     <tr>
	       
	        <td class="tableleft"><span style="color:#f00;">*</span>逾期天数 </td>
	        <td><input type="text" name="late_days" id="late_days" value = "30" class="pubinput" value = "<?php echo $borrow['late_days'];?>"/>天 </td>
	        <td class="tableleft">客户奖励 </td>
	        <td>
	        <?php foreach ($borrow_award as $wk=>$wt){?>
				<input type="radio" value="<?php echo $wk;?>" <?php if($wk == $borrow['award']){?> checked<?php }?>  id="award" name="award" onclick="baward(this)"><?php echo $wt;?>
			<?php }?>
			</td>
	        <td class="tableleft">奖励<span id="fundaward">比例</span> </td>
	        <td><input type="text" name="funds" id="funds" value="<?php echo $borrow['funds'];?>" class="pubinput"/><span id="fundsname"></span> </td>
	       
	    </tr>
	    <tr>
	    	<td class="tableleft">自动投标比例</td>
	    	<td><input type="text" class="pubinput" name="auto_apr" id="auto_apr" value="<?php echo $borrow['auto_apr'];?>" />% </td>
	    	<td class="tableleft"></td>
	    	<td></td>
	    	<td class="tableleft"></td>
	    	<td></td>
	    </tr>
	 </table>
	 <h3>标的背景调查审核</h3>
	 <?php foreach($borrow_fsubject as $sk=>$subject){?>
		<div style="width:99%;overflow:hidden;">
		<input type="checkbox"  <?php if( $sublist && in_array($sk,$sublist)){ ?> checked <?php }?>  value="<?php echo $sk;?>" name="fsubjectid[]" onclick="bgSubject(this);">&nbsp;<?php echo $subject;?>
		<ul style="padding-left:14px;<?php if( $sublist && in_array($sk,$sublist)){ ?> display:block; <?php }else{?>display:none;<?php }?>" id="background_investigation_<?php echo $sk;?>" >
			<li>
				<a  href="javascript:;" onclick="add_fsubject(<?php echo $sk;?>);" class="addtr">上传文件</a>
				<div>
				<ul id="file_att_<?php echo $sk;?>" class="fsubjectlist">
					<?php $i=0; foreach($list as $sb){$i++; if($sk == $sb['id']){ $thumbnailstr = $sb['id'].'|'.$sb['pic'].'|'.$sb['fileformat'].'|'.$sb['valid'].'|'.$sb['content'];?>
						<li id="att_litpic_<?php echo $i;?>">
						<a href="/static/data/upfiles/conset/subject/<?php echo $sb['pic'];?>" target="_blank">
							<img width="60" height="60" src="/static/data/upfiles/conset/subject/<?php echo $sb['pic'];?>">
						</a>
						<br>
						<?php echo $sb['pic'];?><br>
						审核资料有效期:<?php echo $sb['valid'];?>个月<br>
						<p>资料提交说明：<?php echo $sb['content'];?></p>
						<p><span><a href="javascript:subject_remove(<?php echo $i;?>);">删除</a></span></p>
						<input type="hidden" value="<?php echo $thumbnailstr;?>" name="thumbnailstr[]">
					</li>
					<?php }}?>
				</ul>
				</div>								
			</li>								
		</ul>
		</div>
	<?php }?>	
	<hr>
	<h3>标的安全性审核</h3>
	<table class="table table-bordered table-hover m10">
		 <?php if($borrow['ftype'] == 1){?>
		 	<tr>
	        <td class="tableleft">真伪鉴定 </td>
	        <td><input class="input" style="width:500px;" type="text" name="bill_identification" id="bill_identification" value="<?php echo $borrow['bill_identification'];?>" size="30" /> </td>
	        </tr>
	        <tr>
	        <td class="tableleft">鉴定单位 </td>
	        <td><input class="input" style="width:500px;" type="text" name="bill_unit" id="bill_unit" value="<?php echo $borrow['bill_unit'];?>" size="30" /> </td>
	        </tr>
	        <tr>
	        <td class="tableleft">完好性 </td>
	        <td>
	        <?php foreach($borrow_good as $gk=>$good){?>
				<input type="radio" <?php if($gk == $borrow['bill_good']){?> checked <?php }?>  value="<?php echo $gk;?>" id="bill_good" name="bill_good"><?php echo $good;?>
			<?php }?> 
	        </td>
	        </tr>
	        <tr>
	        <td class="tableleft">字体清晰度 </td>
	        <td><input class="input" style="width:500px;" type="text" name="bill_clarity" id="bill_clarity" value="<?php echo $borrow['bill_clarity'];?>" size="30" /> </td>
	        </tr>
	        <tr>
	        <td class="tableleft">用章合规性 </td>
	        <td><input class="input" style="width:500px;" type="text" name="bill_compliance" id="bill_compliance" value="<?php echo $borrow['bill_compliance'];?>" size="30" /> </td>
	        </tr>
	        <tr>
	        <td class="tableleft">扫描件1 </td>
	        <td><input type="file" name="f_file[]" id="bill_edition1"/> </td>
	        </tr>
	        <tr>
	        <td class="tableleft">扫描件2 </td>
	        <td><input type="file" name="f_file[]" id="bill_edition2"/> </td>
	        </tr>
	        <tr>
	        <td class="tableleft">扫描件3 </td>
	        <td><input type="file" name="f_file[]" id="bill_edition3"/> </td>
	        </tr>
	        <tr>
	        <td class="tableleft">扫描件4 </td>
	        <td><input type="file" name="f_file[]" id="bill_edition4"/> </td>
	        </tr>
	        <tr>
	        <td class="tableleft">质押借款协议 </td>
	        <td><input type="file" name="f_file[]" id="bill_protocol"/> </td>
	        </tr>
	        <tr>
	        <td class="tableleft">资金用途 </td>
	        <td>
	        <select id="fuse" name="fuse" class="pubput">
			<option value="0" >--请选择资金用途--</option>
			<?php foreach($borrow_fuse as $fk=>$fuse){?>
			<option <?php if($borrow['fuse']==$fk){?> selected="selected"<?php }?> value="<?php echo $fk;?>" ><?php echo $fuse;?></option>
			<?php }?>
			</select>
	        </td>
	        </tr>
	        <tr>
	        <td class="tableleft">承兑银行 </td>
	        <td>
	        <select name="bill_bank" id="bill_bank" class="pubput">
						<option value="0" >--请选择承兑银行--</option>
						<?php foreach($borrow_bill_bank as $sk=>$bank){?>
							<option <?php if($borrow['bill_bank']==$sk){?> selected="selected"<?php }?> value="<?php echo $sk;?>" ><?php echo $bank;?></option>
						<?php }?>
			</select> 
	        </td>
	        </tr>
	        <tr>
	         <td class="tableleft">保障方式 </td>
	        <td><textarea rows="8" cols="100" id="security_mode" name="security_mode"><?php echo $borrow['security_mode'];?></textarea> </td>
	        </tr>
	        <tr>
	        <td class="tableleft">产品亮点 </td>
	        <td><input class="input" style="width:500px;" type="text" name="summary" id="summary" value="<?php echo $borrow['summary'];?>" size="30" /> </td>
	        </tr>
	        <tr>
	         <td class="tableleft">审核时间 </td>
	        <td><input type="text" name="works_hours" id="works_hours" value="<?php echo $borrow['works_hours'];?>"  class="pubinput"/>小时<font>*默认24小时审核完成</font> </td>
	        </tr>
	      <?php }elseif($borrow['ftype'] == 2){?>
	        <tr>
	        <td class="tableleft">借款人信息 </td>
	        <td><textarea rows="8" cols="100" id="hong_bill_identification" name="hong_bill_identification"><?php echo $borrow['bill_identification'];?></textarea> </td>
	        </tr>
	        <tr>
	         <td class="tableleft">借款描述 </td>
	        <td><textarea rows="8" cols="100" id="hong_bill_unit" name="hong_bill_unit"><?php echo $borrow['bill_unit'];?></textarea> </td>
	       </tr>
	        <tr>
	        <td class="tableleft">还款来源 </td>
	        <td><textarea rows="8" cols="100" id="hong_bill_clarity" name="hong_bill_clarity"><?php echo $borrow['bill_clarity'];?></textarea> </td>
	        </tr>
	        <tr>
	         <td class="tableleft">抵押详情 </td>
	        <td><textarea rows="8" cols="100" id="hong_security_mode" name="hong_security_mode"><?php echo $borrow['security_mode'];?></textarea> </td>
	        </tr>
	        <tr>
	        <td class="tableleft">产品亮点 </td>
	        <td><textarea rows="8" cols="100" id="hong_summary" name="hong_summary"><?php echo $borrow['summary'];?></textarea> </td>
	        </tr>
	      <?php }elseif($borrow['ftype'] == 3){?>
	        <tr>
	        <td class="tableleft">借款人信息 </td>
	        <td><textarea rows="8" cols="100" id="hong_bill_identification" name="hong_bill_identification"><?php echo $borrow['bill_identification'];?></textarea> </td>
	        </tr>
	        <tr>
	        <td class="tableleft">借款描述 </td>
	        <td><textarea rows="8" cols="100" id="hong_bill_unit" name="hong_bill_unit"><?php echo $borrow['bill_unit'];?></textarea> </td>
	        </tr>
	        <tr>
	        <td class="tableleft">还款来源 </td>
	        <td><textarea rows="8" cols="100" id="hong_bill_clarity" name="hong_bill_clarity"><?php echo $borrow['bill_clarity'];?></textarea> </td>
	        </tr>
	        <tr>
	        <td class="tableleft">抵押详情 </td>
	        <td><textarea rows="8" cols="100" id="hong_security_mode" name="hong_security_mode"><?php echo $borrow['security_mode'];?></textarea> </td>
	        </tr>
	        <tr>
	        <td class="tableleft">产品亮点</td>
	        <td><textarea rows="8" cols="100" id="hong_summary" name="hong_summary"><?php echo $borrow['summary'];?></textarea> </td>
	        </tr>
		<?php }?>
	</table>
	<hr>
	 <button type="button" class="btn btn-success"  onclick="borrowSubmit();" >提交</button>
	</form>
</div>


<div id="dialog" title="系统提示" style="display:none"><p id="msg" style="text-align:center"></p></div>
<div id="fsubjectdialog" title="系统提示" style="display:none"><p id="msg" style="text-align:center"></p>
	<div id="borrow_upload_view"></div>
</div>

<script type="text/javascript">

//是否勾选天标
$("#is_day").click(function(){
	if($("#is_day").is(":checked")){
		$("#time_limit_day").show();
		$("#time_limit").attr("disabled",true);
		$("#time_limit").val(1);
		$("#bill_times").val(3);
		$("#style").val(3);
		$("#style").attr("disabled",true);
	}else{
		$("#time_limit_day").hide();
		$("#time_limit").attr("disabled",false);
		$("#style").attr("disabled",false);
		$("#bill_times").val(30);
	}
});


function borrowSubmit(){
	var options = {
		url : '/sys_admin/borrow/edit/',
		beforeSubmit:  checkBorrowForm,
		dataType: "json",
		type:"post",
		success : function(ret) {
			if(ret.msg > 0){
				alert("操作成功");
				window.location.href ='/sys_admin/borrow/zhs_borrow_verify_list';
			}else{
				alert(ret.msg);
			}
			
		}
	};
	$("#borrowForm").ajaxSubmit(options);
	return false;
}
</script>

